﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml;

namespace GameBanChim_Version1
{
    public class MessageStr : Dialog
    {
        // tổng số con chim còn sống:
        private int _nLive = 0;

        public int NLive
        {
            get { return _nLive; }
            set { _nLive = value; }
        }

        private int _iLive;

        public int ILive
        {
            get { return _iLive; }
            set { _iLive = value; }
        }

        // màu mè cho thông báo:
        SpriteFont _font;

        public SpriteFont Font
        {
            get { return _font; }
            set { _font = value; }
        }

        Color _color;

        public Color Color
        {
            get { return _color; }
            set { _color = value; }
        }

        // chuoi thong bao:
        string _messageStr;

        public string MessageStr1
        {
            get { return _messageStr; }
            set { _messageStr = value; }
        }

        // dkien de chuoi thong bao hien len:
        bool _alwayVisible = true;

        public bool AlwayVisible
        {
            get { return _alwayVisible; }
            set { _alwayVisible = value; }
        }
        //_kindOfFont = 1 -> Large, 2 - > Normal, 3 -> Small
        public MessageStr(ContentManager _content, int _kindFont, Color color, string _message)
        {
            if (_kindFont == 1)
                _font = _content.Load<SpriteFont>("LargeFont");
            else if (_kindFont == 2)
                _font = _content.Load<SpriteFont>("NormalFont");
            else
                _font = _content.Load<SpriteFont>("SmallFont");
            _messageStr = _message;
            _color = color;
        }

        public override bool Init(ContentManager Content, int index, string strResourceXML)
        {
            return base.Init(Content, index, strResourceXML);
        }

        public override void Update(GameTime gameTime)
        {
            if (_iLive != _nLive)
            {
                _iLive++;
            }
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (_alwayVisible)
                spriteBatch.DrawString(_font, _messageStr, new Vector2(X, Y), _color);
            else
            {
                if (_iLive != _nLive)
                {
                    spriteBatch.DrawString(_font, _messageStr, new Vector2(X, Y), _color);
                }
            }
        }
    }
}
